/*********************
* Author:Dzlua
* QQ:505544956
* time:2016/11/30
*/
#ifndef __EDUI_LUACONTROL_H__
#define __EDUI_LUACONTROL_H__

#include "../../controls/Control.h"
#include "../LuaHelper.h"

#ifdef EDUI_USE_LUAPLUS

EDUI_NAMESPACE_BEGIN

class LuaControl : public LuaClassBase
{
public:
#ifdef EDUI_TEST_NEW_DELETE
    static int m_newdeleteNum;
    static int _GetNewDeleteNum();
#endif

    LuaControl(Control* ctrl);
    virtual ~LuaControl();
    static void* GetInterface(void* data);
    virtual void Release();
    virtual void* GetCObj();
    static void Register(LuaState *L);
    int SetEvent(LuaState *L);
    int RemoveEvent(LuaState *L);
public:
    const char* GetName();
    bool SetName(const char* name);
    int GetPos(LuaState *L);
    bool SetPos(int x, int y);
    int GetSize(LuaState *L);
    bool SetSize(int w, int h);
    int GetRect(LuaState *L);
    bool SetRect(int x, int y, int w, int h);
    int GetFixedPos(LuaState *L);
    bool SetFixedPos(int x, int y);
    int GetFixedSize(LuaState *L);
    bool SetFixedSize(int w, int h);
    int GetFixedRect(LuaState *L);
    bool SetFixedRect(int x, int y, int w, int h);
    int GetPadding(LuaState *L);
    bool SetPadding(int l, int t, int r, int b);

    bool IsFloat();
    void SetFloat(bool bFloat);
    bool IsVisible();
    void SetVisible(bool bVisible);
    bool IsEnabled();
    void SetEnabled(bool bEnable);
    bool IsMouseEnabled();
    void SetMouseEnabled(bool bEnable);
    bool IsKeyboardEnabled();
    void SetKeyboardEnabled(bool bEnable);
    bool IsFocused();
    void SetFocus();
	void KillFocus();

    bool IsDragWindow();
    bool IsInRect(int x, int y);

    int GetWindow(LuaState *L);
    int GetParent(LuaState *L);
    void Invaldate();

    bool LoadLayout(const char* xmlstr);
    
    int SetCursor(LuaState *L);
    int GetCursor(LuaState *L);

    void SetColor(const char* colorstr);
    int GetColor(LuaState *L);

    void SetImage(const char* imagestr);
    void SetStatusImage(const char* statusimagestr);
    int GetImage(LuaState *L);

    int FindControl(LuaState *L);
    int FindControlByTabID(LuaState *L);
    int FindParent(LuaState *L);

    void SetTabID(int id);
    int GetTabID();

    int SetAnimation(LuaState *L);
    int GetAnimation(LuaState *L);
protected:
    Control* m_cobj;
};

EDUI_NAMESPACE_END

#endif
#endif